home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / comm / tcp / AmiTCPsdk_40.lha / AmiTCP-4.0 / netinclude / stdio.h < prev    next >
C/C++ Source or Header  |  1994-10-03  |  5KB  |  227 lines

  1. #ifndef STDIO_H
  2. #define STDIO_H \
  3.        "$Id: stdio.h,v 4.3 1994/10/03 20:52:20 ppessi Exp $"
  4. /*
  5.  *      Standard ANSI C IO library subset for AmigaOS 2.04 dos.library
  6.  *
  7.  *      Copyright © 1994 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11.  
  12. #ifndef USE_DOSIO
  13. #include <include:stdio.h>
  14. #else
  15.  
  16. #if __SASC
  17. #ifndef  PROTO_DOS_H
  18. #include <proto/dos.h>
  19. #endif
  20. #elif __GNUC__
  21. #ifndef  _INLINE_DOS_H
  22. #include <inline/dos.h>
  23. #endif
  24. #else
  25. #ifndef  CLIB_DOS_PROTOS_H
  26. #include <clib/dos_protos.h>
  27. #endif
  28. #endif
  29.  
  30. #ifndef DOS_DOS_H
  31. #include <dos/dos.h>
  32. #endif
  33.  
  34. #ifndef DOS_STDIO_H
  35. #include <dos/stdio.h>
  36. #endif
  37.  
  38. #ifndef _COMMSIZE_H
  39. #include <sys/commsize.h>
  40. #endif
  41.  
  42. #ifndef _COMMLIST_H
  43. #include <sys/commlist.h>
  44. #endif
  45.  
  46. typedef unsigned long fpos_t;
  47.  
  48. #ifndef _COMMNULL_H
  49. #include <sys/commnull.h>
  50. #endif
  51.  
  52. ULONG VSPrintf(STRPTR, const char *, va_list);
  53. ULONG SPrintf(STRPTR, const char *, ...);
  54.  
  55. #define _IOFBF   BUF_FULL
  56. #define _IONBF   BUF_NONE
  57. #define _IOLBF   BUF_LINE
  58.  
  59. #define BUFSIZ        512
  60. #define EOF        ENDSTREAMCH
  61. #define FOPEN_MAX    20
  62. #define FILENAME_MAX    64
  63. #define L_tmpnam    64
  64.  
  65. #define SEEK_SET OFFSET_BEGINNING    /* Seek from beginning of file */
  66. #define SEEK_CUR OFFSET_CURRENT        /* Seek from current file position */
  67. #define SEEK_END OFFSET_END        /* Seek from end of file */
  68.  
  69. #define TMP_MAX 999             /* Guaranteed unique temp names */
  70.  
  71. typedef long FILE;        /* have to define something */
  72.  
  73. extern BPTR __dosio_files[3];    /* defined in dosio_init.c, autoinitialized */
  74.  
  75. #define stdin  __dosio_files[0]    /* standard input file pointer */
  76. #define stdout __dosio_files[1]    /* standard output file pointer */
  77. #define stderr __dosio_files[2]    /* standard error file pointer */
  78.  
  79. /*
  80.  * Prototypes for ANSI standard functions.
  81.  */
  82.  
  83. #define remove(name) !DeleteFile((STRPTR)(name))
  84.  
  85. #define rename(oldname, newname) !Rename((STRPTR)(oldname), (STRPTR)(newname))
  86.  
  87. #if 0
  88. extern FILE *tmpfile(void);
  89. extern char *tmpnam(char *s);
  90. #endif
  91.  
  92. #define fclose(f) !Close((f))
  93.  
  94. #define fflush(f) ((Flush((f))) ? 0 : EOF)
  95.  
  96. #if 0
  97. extern FILE *fopen(const char *, const char *);
  98. extern FILE *freopen(const char *, const char *, FILE *);
  99.  
  100. extern void setbuf(FILE *, char *);
  101. #endif
  102.  
  103. #define setvbuf(fh, buff, type, size) \
  104.   SetVBuf((fh), (STRPTR)(buff), (type), (size))
  105.  
  106. #define fprintf FPrintf
  107.  
  108. #if 0
  109. extern int fscanf(FILE *, const char *, ...);
  110. #endif
  111.  
  112. #define printf Printf
  113.  
  114. #if 0
  115. extern int scanf(const char *, ...);
  116. #endif
  117.  
  118. /* this is from net.lib, not from dos.library */
  119. #define sprintf SPrintf
  120.  
  121. #if 0
  122. extern int sscanf(const char *, const char *, ...);
  123. #endif
  124.  
  125. #define vfprintf VFPrintf
  126. #define vprintf VPrintf
  127.  
  128. /* this is from net.lib, not from dos.library */
  129. #define vsprintf VSPrintf
  130.  
  131. #define fgetc FGetC
  132.  
  133. #define fgets(buf, len, fh) FGets((fh), (buf), (len))
  134.  
  135. #define fputc(c, fh) FPutC((fh), (c))
  136.  
  137. #define fputs(str, fh) FPuts((fh), (STRPTR)(str))
  138.  
  139. #define getc fgetc
  140.  
  141. #define getchar() getc(stdin)
  142.  
  143. #define gets(buf) fgets((buf), 1024, stdin) /* length is a kludge */
  144.  
  145. #define putc fputc
  146.  
  147. #define putchar(c) putc((c),stdout)
  148.  
  149. #define puts(str) fputs((str), stdout)
  150.  
  151. #define ungetc(c, fh) UnGetC((fh), (c))
  152.  
  153. #define fread(buf, blocklen, blocks, fh) \
  154.   FRead((fh), (APTR)(buf), (blocklen), (blocks))
  155.  
  156. #define fwrite(buf, blocklen, blocks, fh) \
  157.   FWrite((fh), (APTR)(buf), (blocklen), (blocks))
  158.  
  159. #define fgetpos(fh, fposp) (*(fposp) = Seek((fh), 0L, OFFSET_CURRENT), \
  160.                 (*(fposp) == (-1)))
  161.  
  162. #define fseek Seek
  163.  
  164. #define fsetpos(fh, fposp) \
  165.   ((Seek((fh), *(fposp), OFFSET_BEGINNING) == -1) ? EOF : 0)
  166.  
  167. #define ftell(fh) Seek((fh), 0L, OFFSET_CURRENT)
  168.  
  169. #define rewind(fh) (void)Seek((fh), 0L, OFFSET_BEGINNING)
  170.  
  171. #if 0
  172. #define clearerr(fh) SetIoErr(0L) /* not exact */
  173. #endif
  174.  
  175. #if 0
  176. extern int feof(FILE *);
  177. #define feof(p) (((p)->_flag & _IOEOF) != 0)
  178. #endif
  179.  
  180. #if 0
  181. #define ferror(fh) (IoErr() != 0) /* not exact */
  182. #endif
  183.  
  184. /* this is in net.lib */
  185. extern void perror(const char *);
  186.  
  187. #ifndef _STRICT_ANSI
  188.  
  189. /* defines for mode of access() */
  190. #define R_OK 4
  191. #define W_OK 2
  192. #define X_OK 1
  193. #define F_OK 0
  194.  
  195. /*
  196.  * Prototypes for Non-ANSI functions.
  197.  */
  198.  
  199. extern int __io2errno(int);
  200.  
  201. #define fgetchar() fgetc(stdin)
  202.  
  203. #define fputchar(c) fputc((c), stdout)
  204.  
  205. #define setnbf(fh) (void)SetVBuf((fh), NULL, BUF_NONE, -1)
  206.  
  207. extern int __access(const char *, int);
  208. extern int access(const char *, int);
  209. extern int chdir(const char *);
  210. extern int chmod(const char *, int);
  211. extern char *getcwd(char *, int);
  212.  
  213. /* extern int unlink(const char *); in fcntl.h*/
  214.  
  215. #define  clrerr  clearerr
  216. #define  access  __access
  217.  
  218. #endif /* _STRICT_ANSI */
  219.  
  220. #if 0
  221. extern unsigned long __fmask;
  222. extern int __fmode;
  223. #endif
  224.  
  225. #endif /* USE_DOSIO */
  226. #endif /* STDIO_H */
  227.